package com.ruoyi.process.ccs.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.ccs.domain.CcsJdkps;
import com.ruoyi.process.ccs.service.ICcsJdkpsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机电科排水Controller
 *
 * @author Xianlu Tech
 * @date 2020-04-02
 */
@Controller
@RequestMapping("/process/jdkps")
public class CcsJdkpsController extends BaseController {
    private String prefix = "process/jdkps";

    @Autowired
    private ICcsJdkpsService ccsJdkpsService;

    @RequiresPermissions("process:jdkps:view")
    @GetMapping()
    public String jdkps() {
        return prefix + "/jdkps";
    }

    /**
     * 查询机电科排水列表
     */
    @RequiresPermissions("process:jdkps:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CcsJdkps ccsJdkps) {
        startPage();
        List<CcsJdkps> list = ccsJdkpsService.selectCcsJdkpsList(ccsJdkps);
        return getDataTable(list);
    }

    /**
     * 导出机电科排水列表
     */
    @RequiresPermissions("process:jdkps:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CcsJdkps ccsJdkps) {
        List<CcsJdkps> list = ccsJdkpsService.selectCcsJdkpsList(ccsJdkps);
        ExcelUtil<CcsJdkps> util = new ExcelUtil<CcsJdkps>(CcsJdkps.class);
        return util.exportExcel(list, "jdkps");
    }

    /**
     * 新增机电科排水
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存机电科排水
     */
    @RequiresPermissions("process:jdkps:add")
    @Log(title = "机电科排水", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CcsJdkps ccsJdkps) {
        return toAjax(ccsJdkpsService.insertCcsJdkps(ccsJdkps));
    }

    /**
     * 修改机电科排水
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        CcsJdkps ccsJdkps = ccsJdkpsService.selectCcsJdkpsById(id);
        mmap.put("ccsJdkps", ccsJdkps);
        return prefix + "/edit";
    }

    /**
     * 修改保存机电科排水
     */
    @RequiresPermissions("process:jdkps:edit")
    @Log(title = "机电科排水", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CcsJdkps ccsJdkps) {
        return toAjax(ccsJdkpsService.updateCcsJdkps(ccsJdkps));
    }

    /**
     * 删除机电科排水
     */
    @RequiresPermissions("process:jdkps:remove")
    @Log(title = "机电科排水", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(ccsJdkpsService.deleteCcsJdkpsByIds(ids));
    }
}
